package com.ln.prac.base.stream;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <pre>
 *  StreamTest
 * </pre>
 *
 * @Author zhangj
 * @Date 2022/9/18 22:02
 */
public class StreamTest {

    public static void main(String[] args) {
        List<A> list = new ArrayList<>();
        list.add(new A("a1", "a2"));
        list.add(new A("b1", "b2"));
        list.add(new A("c1", "c2"));
        list.add(new A("d1", "d2"));
        list.add(new A("e1", "e2"));

        System.out.println(list.stream().map(A::getCode).collect(Collectors.toList()));

//        System.out.println(list.stream().flatMap(x -> x.getCode()).collect(Collectors.toList()));

    }


    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class A {
        private String name;
        private String code;


    }

}

